package com.translate.web.api.controller;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import com.translate.web.api.enums.OrderNodeEnums;
import com.translate.web.api.service.IMgOrderNodeRecordService;
import com.translate.web.param.*;

import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.NativeWebRequest;
import com.translate.vo.ManuscriptVO;
import com.translate.vo.OrderVO;
import com.translate.vo.ServiceTypeVO;
import com.response.vo.ResponseModel;
import com.controller.base.AbstractCommonController;
import com.page.PageResponseData;
import com.translate.web.constant.Constant;
import com.translate.web.constant.RedisConstant;
import com.translate.web.constant.RedisExpireTime;
import com.translate.web.constant.UserStatus;
import com.translate.web.param.contract.IIdAndUserIdParam;
import com.translate.web.param.contract.IOrderAddParam;
import com.translate.entity.NoticeCenter;
import com.translate.entity.Order;
import com.translate.entity.OrderLog;
import com.translate.entity.ServiceType;
import com.translate.entity.User;
import com.translate.web.service.IChangeRecordService;
import com.translate.web.service.IManuscriptService;
import com.translate.web.service.INoticeCenterService;
import com.translate.web.service.IOrderLogService;
import com.translate.web.service.IOrderService;
import com.translate.web.service.IPayManagerService;
import com.translate.web.service.IPayTypeService;
import com.translate.web.service.IServiceTypeService;
import com.translate.web.service.IUserService;
import com.basic.service.contract.IBaseService;
import com.common.util.ListConvertMap;
import com.common.util.MergeDataSource;

@RestController
@RequestMapping("order")
public class OrderController extends AbstractCommonController<Order, OrderSearchParam> {
	private IOrderService service;

	private IManuscriptService manuscriptService;

	private IPayManagerService payManagerService;
	
	IServiceTypeService serviceTypeService;

	IPayTypeService payTypeService;

	IUserService userService;

	IOrderLogService orderLogService;

	IChangeRecordService changeRecordService;
	
	INoticeCenterService centerService;
	@Resource
	public void setCenterService(INoticeCenterService centerService) {
		this.centerService = centerService;
	}

	@Resource
	private IMgOrderNodeRecordService iMgOrderNodeRecordService;

	
	
	@Resource
	public void setServiceTypeService(IServiceTypeService serviceTypeService) {
		this.serviceTypeService = serviceTypeService;
	}

	@Resource
    public void setOrderLogService(IOrderLogService orderLogService) {
        this.orderLogService = orderLogService;
    }

	@Resource
    public void setChangeRecordService(IChangeRecordService changeRecordService) {
        this.changeRecordService = changeRecordService;
    }

	@Resource
    public void setUserService(IUserService userService) {
        this.userService = userService;
    }


	@Resource
	public void setPayTypeService(IPayTypeService payTypeService) {
		this.payTypeService = payTypeService;
	}

	@Resource
	public void setManuscriptService(IManuscriptService manuscriptService) {
		this.manuscriptService = manuscriptService;
	}

	public OrderController(IOrderService service) {
		this.service = service;
	}

	protected long setCreateInfo(IOrderAddParam param, NativeWebRequest httpServletRequest) {
		long userId = this.getUserId(httpServletRequest);
		param.setUserId((int) userId);
		return userId;
	}


	@PostMapping(value = "/teamListByAssocSearchVO")
	public ResponseModel<PageResponseData<OrderVO>> teamListByAssocSearchVO(
			@RequestBody @Validated OrderSearchByTeamParam orderBySearchParam,
			NativeWebRequest httpServletRequest) {

		long userId = this.getUserId(httpServletRequest);

		super.frontProcesserVO(orderBySearchParam, httpServletRequest);

		User userInfoToCache = userService.getUserInfoToCache((int) userId);

		if(0 == userInfoToCache.getIsRegimental()) {
			return ResponseModel.errorMsg(null, "您不是团长");
		}

		orderBySearchParam.setTeamId(userInfoToCache.getTeamId());

		String realname = orderBySearchParam.getRealname();

		List<User> userIdsByRealname = null;

		long userIdParam = orderBySearchParam.getUserId();

		long [] ids = null;

		if (null != realname) {

			userIdsByRealname = userService.getUserIdsByRealname(orderBySearchParam.getRealname());

			ids = userIdsByRealname.stream().mapToLong(User::getId).toArray();

			if (0 != userIdParam) {

				int flag = 0;

				for (int i = 0; i < ids.length; i++) {
					if (ids[i]==userId) {
						flag = 6;
					}
				}

				if (0 == flag) {
					// 说明用户里面没有这个 id;
					return ResponseModel.success(new PageResponseData<>());
				}

			}
		}
		orderBySearchParam.setUserIds(ids);
		PageResponseData<OrderVO> orderListByTeam = this.service.getOrderListByTeam(orderBySearchParam, OrderVO.class);

		long total = orderListByTeam.getTotal();

		if (0 == total) {
			return ResponseModel.success(orderListByTeam);
		}

		List<OrderVO> data = orderListByTeam.getData();
		QB:	
		if (null == userIdsByRealname) {
			
			if (null == data) {
				break QB;
			}
			
            userIdsByRealname = this.userService.getDataByIds(data.stream().mapToLong(OrderVO::getUserId).toArray());
		}
        if (null == userIdsByRealname) {

        	return ResponseModel.success(orderListByTeam);
        }

        Map<Long, User> listToMap = ListConvertMap.listToMap(userIdsByRealname, User::getId);

        MergeDataSource<OrderVO> dataSource = new MergeDataSource<OrderVO>(data);

        Function<OrderVO, Long> function = (e) -> e.getUserId().longValue();

        dataSource.mergeRelease(function, listToMap, (order, user) -> {
        	order.setUserName(user.getRealname());
            return order;
        });

        return ResponseModel.success(orderListByTeam);
	}

	
	private Order orderDatail( int id, int userId) {
		
		IIdAndUserIdParam param = new IdAndUserIdParam();
		
		param.setId(id);
		
		param.setUserId(userId);
		
		String orderDeteilKey = RedisConstant.getOrderDeteilKey(id, userId);
		
		return this.service.getDataDetailFromCache(param, orderDeteilKey, 1);
		
	}
	
	
	/**
	 * 报账合同申请
	 * @param orderBySearchParam
	 * @param httpServletRequest
	 * @return
	 */
	@PostMapping(value = "/applicationForReimbursementContract")
	@Transactional
	public ResponseModel<Integer> applicationForReimbursementContract(
			@RequestBody @Validated OrderApplyParam orderApplyParam,
			NativeWebRequest httpServletRequest)
	{
		long userId = this.getUserId(httpServletRequest);
		
		
		Integer id = orderApplyParam.getId();
		Order dataDetailFromCache = orderDatail(id,  (int) userId);
		

		if (null == dataDetailFromCache.getId()) {
            return ResponseModel.errorMsg(0, "找不到该订单");
        }
		
		if (1 == dataDetailFromCache.getNeedContract()) {
            return ResponseModel.errorMsg(0, "该订单已申请过报账合同");
        }
		
		
		orderApplyParam.setUserId((int) userId);

		int status = this.service.applicationForReimbursementContract(orderApplyParam);

//		张三(ID:12345678)【多轮翻译】订单KT231024123456申请【报账合同】，请及时查看处理!
		
		User userInfoToCache = this.userService.getUserInfoToCache((int) userId);
		
		
		ServiceType listFromCache = this.serviceTypeService.selectByPrimaryKey(dataDetailFromCache.getServiceId());
		
		String content = 
				userInfoToCache.getRealname()
				+ "(ID:" + userInfoToCache.getId()+")【"+listFromCache.getTypeName()+"】"
				+ "订单" + dataDetailFromCache.getOrderSnId()+"申请【报账合同】，请及时处理！";
		
		this.centerService.orderNotice("申请报账合同通知", (int) userId, id, content, (byte)1);
		
		return ResponseModel.success(status);
	}

	/**
	 * 翻译证明
	 * @param orderBySearchParam
	 * @param httpServletRequest
	 * @return
	 */
	@PostMapping(value = "/needTranslationProof")
	@Transactional
	public ResponseModel<Integer> needTranslationProof(
			@RequestBody @Validated OrderApplyParam orderApplyParam,
			NativeWebRequest httpServletRequest)
	{
		long userId = this.getUserId(httpServletRequest);
		
		Integer id = orderApplyParam.getId();
		Order dataDetailFromCache = orderDatail(id,  (int) userId);
		

		if (null == dataDetailFromCache.getId()) {
            return ResponseModel.errorMsg(0, "找不到该订单");
        }
		
		if (1 == dataDetailFromCache.getNeedTranslationProof()) {
            return ResponseModel.errorMsg(0, "该订单已申请过翻译润色证明");
        }
		
		orderApplyParam.setUserId((int) userId);

		int status = this.service.needTranslationProof(orderApplyParam);

		if (-1 == status) {
			return ResponseModel.errorMsg(0, "找不到该订单");
		}

		if (-2 == status) {
			return ResponseModel.errorMsg(0, "该订单不是翻译证明");
		}
		
		
//		张三(ID:12345678)【多轮翻译】订单KT231024123456申请【报账合同】，请及时查看处理!
		
		User userInfoToCache = this.userService.getUserInfoToCache((int) userId);
		
		ServiceType listFromCache = this.serviceTypeService.selectByPrimaryKey(dataDetailFromCache.getServiceId());
		
		String content = 
				userInfoToCache.getRealname()
				+ "(ID:" + userInfoToCache.getId()+")【"+listFromCache.getTypeName()+"】"
				+ "订单" + dataDetailFromCache.getOrderSnId()+"申请【翻译润色证明】，请及时处理！";
		
		this.centerService.orderNotice("申请翻译证明通知", (int) userId, id, content, (byte)1);
		

		return ResponseModel.success(status);
	}

	/**
	 * 取消订单
	 * @param param
	 * @return
	 */
	@PostMapping("cancelOrderSingle")
	@Transactional
	public ResponseModel<Integer> cancelOrder(@RequestBody @Validated IdAndUserIdParam param, NativeWebRequest httpServletRequest) {

		long userId = this.getUserId(httpServletRequest);
		param.setUserId(userId);

		Order dataDetail = this.service.getDataDetail(param);

		if (dataDetail == null) {
            return ResponseModel.<Integer>errorMsg(0, "订单不存在");
        }

		if (UserStatus.CANCELLED.getStatusCode() == dataDetail.getUserStatus()) {
            return ResponseModel.<Integer>errorMsg(0, "订单已取消");
        }

		this.service.cancelOrder(param);

		// 2024-02-22新增：新增取消订单节点记录
//		iMgOrderNodeRecordService.saveOrderNodeRecord(param.getId(), OrderNodeEnums.CANCEL_ORDER.getCode(), OrderNodeEnums.CANCEL_ORDER.getValue(), "用户端取消订单");
		if (1 == dataDetail.getServiceType()) {
			return ResponseModel.<Integer>success(1);
		}
		
		ServiceType selectByPrimaryKey = serviceTypeService.selectByPrimaryKey(dataDetail.getServiceId());

		Integer payManagerId = dataDetail.getPayManagerId();
		boolean cancelledByPayManager = this.service.isCancelledByPayManager(userId, payManagerId.longValue());

		//如果是查重券支付，需要返还查重券
		if(dataDetail.getUseCheckConpon() == 1){
			payManagerService.cancelTicket((int)userId);
		}

		// 支付管理 减少钱数
		int updateMoney = payManagerService.
				updateMoney(
						payManagerId, 
						dataDetail.getActualPaidPrice(),
						selectByPrimaryKey.getTypeName(), cancelledByPayManager);

		return ResponseModel.<Integer>success(updateMoney);
	}

	// 1 反馈 2 售后3
	static String[] notices = new String[] {
			"",
			"反馈",
			"售后"
	};
	
	/**
     * 二次服务-售后
     * @param param
     * @return
     */
	@PostMapping("secondaryService")
	@Transactional
	public ResponseModel<Integer> secondaryService(@RequestBody @Validated SecondaryServiceParam<ManuscriptAddParam> param, NativeWebRequest request) {

		param.setOrderId(param.getId());

		long userId = this.getUserId(request);
		param.setUserId(userId);

		Order dataDetail = this.service.getDataDetail(param);

		if (null == dataDetail) {
			 return ResponseModel.<Integer>errorMsg(0, "找不到订单");
		}
		
//		if (UserStatus.RETURNED.getStatusCode() != dataDetail.getUserStatus()) {
//            return ResponseModel.<Integer>errorMsg(0, "不是".concat(UserStatus.RETURNED.getDescription()));
//        }
		

		if (UserStatus.CANCELLED.getStatusCode() == dataDetail.getUserStatus()) {
            return ResponseModel.<Integer>errorMsg(0, UserStatus.CANCELLED.getDescription());
        }

		if (UserStatus.PENDING_PAYMENT.getStatusCode() ==dataDetail.getUserStatus()) {
			return ResponseModel.<Integer>errorMsg(0, UserStatus.PENDING_PAYMENT.getDescription());
		}

		if (UserStatus.PENDING_APPROVAL.getStatusCode() ==dataDetail.getUserStatus()) {
			return ResponseModel.<Integer>errorMsg(0, "已在审核中请勿重复提交");
		}


		// 修改 订单状态
		this.service.updateService(param);

        param.setUserId(userId);

        Integer payManagerId = dataDetail.getPayManagerId();
		int logId = this.orderLogService.secondaryService(param, payManagerId);

        int res = this.manuscriptService.secondaryService(param, payManagerId, logId);

        // 通知管理端 姓名(ID:12345678)【服务名称】订单ZF202xxxxxxxXXXX申请售后服务，请及时查看处理!
        
        User userInfoToCache = userService.getUserInfoToCache((int) userId);
        
        NoticeCenter center = new NoticeCenter();

		center.setUserId((int) userId);
		
		ServiceType selectByPrimaryKey = serviceTypeService.selectByPrimaryKey(dataDetail.getServiceId());

		
		
		String typeNotice = notices[param.getServiceStatus()];
		center.setNoticeContent(userInfoToCache.getRealname() + "(ID:"+userId+")【" + selectByPrimaryKey.getTypeName() + "】订单"
				+ dataDetail.getOrderSnId()+ "申请"+typeNotice+"服务，请及时查看处理!。");

		center.setPlatform((byte) 1);

		center.setNoticeType((byte) 1);

		center.setTitle(typeNotice+"审核通知");
		
		center.setTypeId(dataDetail.getId());

		centerService.insert(center);
		
		
		// 的【服务名称】订单ZF202XXXXXXXXXXX售后服务申请已提交，请耐心等待平台处理。
		center = new NoticeCenter();

		center.setUserId((int) userId);
		
		
		center.setNoticeContent( "您的【" + selectByPrimaryKey.getTypeName() + "】订单"
				+ dataDetail.getOrderSnId()+ "申请"+typeNotice+"服务已提交，请耐心等待平台处理。");

		center.setPlatform((byte) 0);

		center.setNoticeType((byte) 1);

		center.setTitle(typeNotice+"审请");
		
		center.setJump((byte) 1);
		
		center.setTypeId(dataDetail.getId());

		centerService.insert(center);
		
        
        return ResponseModel.<Integer>success(res);
	}

	/**
	 * 取消二次服务
	 */
	@PostMapping("cancelSecondaryService")
	@Transactional
	public ResponseModel<Integer> cancelSecondaryService(@RequestBody @Validated IdAndUserIdParam param, NativeWebRequest request) {

		long userId = this.getUserId(request);
		param.setUserId(userId);

		Order dataDetail = this.service.getDataDetail(param);


		if (UserStatus.PENDING_APPROVAL.getStatusCode() !=dataDetail.getUserStatus()) {
			return ResponseModel.<Integer>errorMsg(0, "未提交二次服务或已完成二次服务");
		}

		this.service.cancelSecondaryService(param, dataDetail);

		Byte serviceStatus = dataDetail.getServiceStatus();
		OrderLog log = this.orderLogService.selectSecondaryService(param, Constant.SECONDARY_T_SERVICE.get(serviceStatus));

		// 添加一条日志
		SecondaryServiceParam secondaryServiceParam = new SecondaryServiceParam<>();

		secondaryServiceParam.setOrderId(param.getId());

		secondaryServiceParam.setUserId(userId);

		secondaryServiceParam.setRequirement("取消二次服务");

		Byte normalStatus = Constant.SECONDARY_SERVICE.get(serviceStatus);
		secondaryServiceParam.setServiceStatus(normalStatus);

		Integer payManagerId = dataDetail.getPayManagerId();
		this.orderLogService.secondaryServiceCancelLog(secondaryServiceParam, payManagerId);

		int res = this.manuscriptService.cancelSecondaryService(param,
				log.getId(), normalStatus);
		// 2024-02-23新增：取消二次服务记录时间轴节点
//		iMgOrderNodeRecordService.saveOrderNodeRecord(param.getId(), OrderNodeEnums.CANCEL_SECOND_SERVICE.getCode(), OrderNodeEnums.CANCEL_SECOND_SERVICE.getValue(), "用户端取消二次服务");

		return ResponseModel.<Integer>success(res);
	}


	/**
	 * 评论订单
	 * @param commentParam
	 * @param nativeWebRequest
	 * @return
	 */
	@PostMapping("commentScore")
	public ResponseModel<Integer> commentScore(@RequestBody @Validated OrderCommentParam commentParam, NativeWebRequest nativeWebRequest) {

		Order selectByPrimaryKey = this.service.selectByPrimaryKey(commentParam.getId());
		
		if ( null == selectByPrimaryKey) {
			return ResponseModel.<Integer>errorMsg(500, "找不到订单");
		}
		
		commentParam.setUserId(this.getUserId(nativeWebRequest));
		int result = this.service.commentOrder(commentParam);
		
		if (0 == result) {
			return ResponseModel.<Integer>errorMsg(500, "评论失败,找不到订单");
		}
		
		orderLogService.commentOrderLog(commentParam, selectByPrimaryKey.getPayManagerId());
		
		return ResponseModel.<Integer>success(result);
	}

	/**
	 * 作图立即支付
	 * @return
	 */
	@PostMapping("drawingServiceForImmediatePayment")
    @Transactional
	public ResponseModel<Integer> drawingServiceForImmediatePayment(
			@RequestBody @Validated PayBehaviorRequestParam payBehaviorRequestParam,
			NativeWebRequest object)
	{

		int userId = (int) this.getUserId(object);
		payBehaviorRequestParam.setUserId(userId);
//
//		Integer payType = payBehaviorRequestParam.getPayType();
//
//		PayType valueFromHash = this.payTypeService.getValueFromHash(RedisConstant.PAY_TYPE, payType.toString());
//
//		IBaseService[] baseService = new IBaseService[] {
//				service,
//				userService,
//				orderLogService,
//				changeRecordService
//		};
//
//		PayFactory.addOperationClass(0, new NormalPayByOrder<>(baseService));
//
//		PayFactory.addOperationClass(1, new RechargePayByOrder<>(baseService));
//
//		IPaymentBehavior operationClass = PayFactory.getTrendsClass((int)valueFromHash.getIsSpecial().intValue());
//
//		Context context = new Context(operationClass);
//
//		int run = context.run(payBehaviorRequestParam);
//
//		OrderErrorMsg errorMsg = OrderErrorMsg.getErrorMsg(run);
//
//		if (null != errorMsg) {
//			return ResponseModel.<Integer>errorMsg(errorMsg.getCode(), errorMsg.getMsg());
//		}
//
//		return ResponseModel.success(run);
		
		Order selectByPrimaryKey = service.selectByPrimaryKey(payBehaviorRequestParam.getId());
	
		ServiceType serviceType = serviceTypeService.selectByPrimaryKey(selectByPrimaryKey.getServiceId());

		
		BigDecimal totalMoney = selectByPrimaryKey.getActualPaidPrice()
				.add(selectByPrimaryKey.getUrgentMoney())
				.subtract(selectByPrimaryKey.getCouponDeductible());
		
		int id = payManagerService.drawAndPayImmediately(
				payBehaviorRequestParam, totalMoney, selectByPrimaryKey.getTeamId(), 
				selectByPrimaryKey.getOrderSnId(), serviceType.getTypeName());
		
		service.setPayManagerByOrderData(payBehaviorRequestParam, id);
		
		
//		orderLogService.drawOrderLog(payBehaviorRequestParam);
		
		return ResponseModel.<Integer>success(id);
		
	}


	/**
	 * 添加
	 *
	 * @param <V>
	 * @param param
	 * @return
	 */
	@PostMapping("/add")
	public ResponseModel<Integer> insert(@RequestBody @Validated OrderAddParam param,
			NativeWebRequest httpServletRequest) {
		setCreateInfo(param, httpServletRequest);
		int id = this.service.parseInsert(param, Order.class);

		return ResponseModel.<Integer>success(id);
	}

	/**
     * 查看 详情
     *
     * @param <V>
     * @param param
     */
	@PostMapping("getOrderDetails")
 	public ResponseModel<OrderVO> getOrderDetails(@RequestBody @Validated IdAndUserIdParam param,
 			NativeWebRequest httpServletRequest) {

		long userId = this.getUserId(httpServletRequest);
		param.setUserId(userId);

		String orderDeteilKey = RedisConstant.getOrderDeteilKey(param.getId(), param.getUserId());

		OrderVO<ManuscriptVO> orderVO = this.service.getDataByIdFromCache(param, OrderVO.class, orderDeteilKey, RedisExpireTime.ORDER_DETAIL);

		orderVO.setUserId(null);

		String mKey = RedisConstant.getManuscriptKey(param.getId(), param.getUserId());

		// 查询 稿件
		List<ManuscriptVO> datasByIdFromCache = manuscriptService.getDatasByIdFromCache(param, ManuscriptVO.class, mKey, 2);

		orderVO.setFiles(datasByIdFromCache);

		return ResponseModel.<OrderVO>success(orderVO);
 	}



	@Override
	protected void frontProcesserVO(OrderSearchParam param, NativeWebRequest object) {
		// TODO Auto-generated method stub
		super.frontProcesserVO(param, object);

		param.setUserId(this.getUserId(object));

	}

	/**
	 * 余额 使用记录
	 */
	@PostMapping("/useBalanceList")
	public ResponseModel<PageResponseData<OrderVO>> getUseBalanceList(@RequestBody @Validated OrderSearchParam dateRangeParam, NativeWebRequest httpServletRequest) {

		this.frontProcesserVO( dateRangeParam, httpServletRequest);

		long userId = this.getUserId(httpServletRequest);
		
		User userInfoToCache = this.userService.getUserInfoToCache((int) userId);
		
		
		dateRangeParam.setUserId(userId);

		
		
		PageResponseData<OrderVO> ordersByUseRecharge = this.service.getOrdersByUseRecharge(
				dateRangeParam, OrderVO.class,
				userInfoToCache.getIsRegimental(),
				userInfoToCache.getTeamId());

//		List<OrderVO> data = ordersByUseRecharge.getData();
		
//		if (0 == data.size()) {
//			return ResponseModel.<PageResponseData<OrderVO>>success(ordersByUseRecharge);
//		}
//		
//		List<ServiceTypeVO> listFromCache = serviceTypeService.getListFromCache(ServiceTypeVO.class);
//		
//		Map<Integer, ServiceTypeVO> listToMap = ListConvertMap.listToMap(listFromCache, ServiceTypeVO::getId);
//		
//		MergeDataSource<OrderVO> dataSource = new MergeDataSource<OrderVO>(data);
//		
//		dataSource.mergeRelease(OrderVO::getServiceId, listToMap, (order, item) -> {
//			
//			order.setServiceTypeName(item.getTypeName());
//			
//			return order;
//		});
		
		
		return ResponseModel.<PageResponseData<OrderVO>>success(ordersByUseRecharge);
	}


	@Override
	protected IBaseService<Order> getBaseService() {
		return this.service;
	}

	/**
	 * 添加
	 *
	 * @param <V>
	 * @param param
	 * @return
	 */
	@PostMapping("/update")
	public ResponseModel<Integer> update(@Validated @RequestBody OrderUpdateParam param,
			HttpServletRequest httpServletRequest) {
		int res = this.service.parseUpdate(param, Order.class);
		return ResponseModel.<Integer>success(res);
	}
	
	
	/**
	 * 删除
	 * 
	 * @param <V>
	 * @param param
	 * @return
	 */
	@PostMapping("/deleteById")
	public ResponseModel<Integer> delete(@Validated @RequestBody IdAndUserIdParam idParam,
			NativeWebRequest request) {
		
		idParam.setUserId(this.getUserId(request));

		int res = this.service.deleteByIdAndUserId(idParam);

		return ResponseModel.<Integer>success(res);
	}

	

	protected <VO> Class<VO> getTarget() {
		return (Class<VO>) OrderVO.class;
	}

	@Resource
	public void setPayManagerService(IPayManagerService payManagerService) {
		this.payManagerService = payManagerService;
	}
}
